package com.example.administrator.u17.utils;



import com.example.administrator.u17.R;

import java.lang.reflect.Field;
import java.util.ArrayList;

/**
 * Created by Administrator on 2016/10/17.
 */
public class IdUtils {
    //获取知道id名称开头的id的值
    public static ArrayList<Integer> getIds(String idName)
    {
        ArrayList<Integer> list=new ArrayList<>();
        Class<R.id> cls= R.id.class;
        Field[] arrf=cls.getDeclaredFields();
        for (Field field : arrf) {
            if(field.getName().startsWith(idName)){
                try {
                    list.add(field.getInt(null));
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
        return list;
    }
}
